const {ccclass, property} = cc._decorator;

@ccclass
export default class MirrorEndControl extends cc.Component {

    @property({tooltip: "对应的事件", type: cc.Component.EventHandler})
    toolEvent: cc.Component.EventHandler[] = [];
    @property({tooltip: "替换图片", type:cc.SpriteFrame})
    launcherSprite: cc.SpriteFrame[] = [];

    // onLoad () {}

    start () {
        console.log(this.launcherSprite);
    }

    event(dir){
        cc.Component.EventHandler.emitEvents(this.toolEvent, [dir]);
        // console.log(this.launcherSprite[1])
        if(this.node.getComponent(cc.Sprite)){
            this.node.getComponent(cc.Sprite).spriteFrame = dir == 1 ? this.launcherSprite[1] : this.launcherSprite[0];
        }else{
            this.node.children[1].getComponent(cc.Sprite).spriteFrame = dir == 1 ? this.launcherSprite[1] : this.launcherSprite[0];
        }
    }

    // update (dt) {}
}
